<template>
  <NuxtLayout>
    <NuxtPage />
  </NuxtLayout>
</template>
<script setup>
const { state, updateLang } = usePageData()
const { state: stateData } = useData()

const { $apiFetch } = useNuxtApp()
const { data, error } = await useAsyncData('index-data', () =>
  Promise.all([
    $apiFetch(`/index`, {
      method: 'GET',
      params: {
        lang: state.value.language,
      },
    }),
    $apiFetch(`/menu`, {
      method: 'GET',
      params: {
        lang: state.value.language,
      },
    }),
    $apiFetch(`/footer`, {
      method: 'GET',
      params: {
        lang: state.value.language,
      },
    }),
  ]),
)
if (!error.value) {
  state.value.indexData = data.value[0].data
  stateData.value.indexData = data.value[0].data
  stateData.value.configMenu = data.value[1].data
  stateData.value.footerMenu = data.value[2].data
}
</script>
